package com.binhthuan.catechist.client.grid;

import com.binhthuan.catechist.client.ECApplication;
import com.binhthuan.catechist.client.component.GridCellFormatter;
import com.binhthuan.catechist.client.data.ScheduleDS;
import com.binhthuan.catechist.shared.constant.Parameter;
import com.smartgwt.client.widgets.grid.ListGridField;

/**
 * @author dttgiang
 * 
 */
public class ScheduleGrid extends AbstractGrid {

    /**
     * @param dataSource
     */
    public ScheduleGrid(ScheduleDS dataSource) {
        super(dataSource);
        setWrapCells(true);
        setFixedRecordHeights(false);

        ListGridField id = new ListGridField(Parameter.ID);
        id.setHidden(true);
        id.setCanHide(false);

        ListGridField dateField = new ListGridField(Parameter.DATE_OF_YEAR);
        dateField.setTitle(ECApplication.getConstants().date());
        dateField.setWidth(80);
        //dateField.setOptionDataSource(DateDS.getInstance());
        //dateField.setOptionCriteria(new Criteria(Parameter.DOCTRINE_CLASS, ECUser.getCurrentClassId().toString()));
        //dateField.setValueField(Parameter.ID);
        //dateField.setDisplayField(Parameter.DATE_OF_YEAR);
        //dateField.setType(ListGridFieldType.DATE);

        ListGridField liturgicalField = new ListGridField(Parameter.LITURGICAL_DATE);
        liturgicalField.setTitle(ECApplication.getConstants().liturgicalDate());

        ListGridField titleField = new ListGridField(Parameter.TITLE);
        titleField.setTitle(ECApplication.getConstants().title());
        titleField.setWidth(80);

        ListGridField contentField = new ListGridField(Parameter.CONTENT);
        contentField.setTitle(ECApplication.getConstants().content());
        contentField.setCellFormatter(new GridCellFormatter());

        ListGridField commentField = new ListGridField(Parameter.COMMENT);
        commentField.setTitle(ECApplication.getConstants().comment());
        commentField.setCellFormatter(new GridCellFormatter());

        ListGridField statusField = new ListGridField(Parameter.STATUS_NAME);
        statusField.setTitle(ECApplication.getConstants().status());
        statusField.setWidth(80);
        //statusField.setOptionDataSource(ScheduleStatusDS.getInstance());
        //statusField.setValueField(Parameter.ID);
        //statusField.setDisplayField(Parameter.NAME);
        
        setSortField(Parameter.DATE_OF_YEAR);
        setFields(id, dateField, liturgicalField, titleField, contentField, commentField, statusField);
    }
}
